<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <div>
            商品数量：<input type="text" v-model="count">
        </div>
        <div>
            单价：{{price}}元
        </div>
        <div>
            总金额：{{amount}}元
        </div>

        <div>
            firstname:<input type="text" v-model="firstname">
        </div>

        <div>
            lastname:<input type="text" v-model="lastname">
        </div>

        <div>
            fullname:<input type="text" v-model="fullname">
        </div>
    </div>
</body>
<script>

    new Vue({
        el:'#app',
        data(){
            return{
                count:10,
                price:2,
                firstname:'',
                lastname:''
            }
        },
        computed:{
            amount(){
                return this.count*this.price
            },
            fullname:{
                get(){
                    return this.firstname+' '+this.lastname
                },
                set(newValue){
                    let names=newValue.split(' ')
                    this.firstname=names[0]
                    this.lastname=names[1]
                }
            }
        }
    })
</script>
</html>